package com.example.teacherservice.dto;

import com.example.teacherservice.entity.Student;
import com.example.teacherservice.entity.User;
import lombok.Data;

@Data
public class StudentDetailDTO {
    private Long studentId;
    private String stuName;
    private Long stuStudyTime;
    private Long stuScore;
    private String clock;
    private Long userId;
    private String username;
    private String userPic;
    private Integer userRole;

    public StudentDetailDTO(Student student) {
        this.studentId = student.getId();
        this.stuName = student.getStuName();
        this.stuStudyTime = student.getStuStudyTime();
        this.stuScore = student.getStuScore();
        this.clock = student.getClock();

        User user = student.getUser();
        if (user != null) {
            this.userId = user.getId();
            this.username = user.getUsername();
            this.userPic = user.getPic();
            this.userRole = user.getRole();
        }
    }
}